package com.binfenhulian.chinaenergy.ces.utils.base;

import com.binfenhulian.chinaenergy.ces.utils.base.Base64;

import java.io.ByteArrayOutputStream;
import java.util.zip.InflaterOutputStream;

public class Base64Util {
    public static String decompressData(String encdata) {
        try {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            InflaterOutputStream zos = new InflaterOutputStream(bos);
            zos.write(getdeBASE64inCodec(encdata));
            zos.close();
            return new String(bos.toByteArray());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return "ERROR";
    }

    public static byte[] getdeBASE64inCodec(String s) {
        if (s == null)
            return null;
        return new Base64().decode(s);
    }

    public static byte[] base64ToByte(String base64Data) {
        byte[] bytes = new Base64().decode(base64Data);
        return bytes;
    }
}